package ControlLayer;
import TUILayer.*;
import ModelLayer.*;

/**
 * This is the controler of the addressbook, it make the connection between the modemLayer and the TUI.
 * 
 * @author (Group2) 
 * @version (1)
 */
public class AddressCtr
{
  private static final AddressCtr instance = new AddressCtr();
  private AddressBook addressBook;
  
  
  public static AddressCtr getInstance()
  {
        return instance;    
  }
  
  public AddressCtr()
        {
            addressBook=ModelLayer.AddressBook.getInstance();
        }

  // start calling methods from the ModemLayer      
   public void getListOfPersons()
        {           
            addressBook.getList();
        }
   
   public void createPerson(String id, String name, String address, int postalCode, String city, String phone)
        {
            addressBook.createPerson(id, name, address, postalCode, city, phone);
            
        }   
        
   public void deletePerson(String id)
        {
            addressBook.deletePerson(id);
        }
        
   public void getPerson(String id)
        {
            addressBook.getPerson(id);
        }
        
   public void updateName(String id, String name)
        {
            addressBook.updatePersonName(id,name);
        }
        
   public void updateAddress(String id,String address)
        {
             addressBook.updatePersonAddress(id,address);
        }
        
   public void updatePostalCode(String id, int postalCode)
        {
            addressBook.updatePersonPostalCode(id,postalCode);
        }
        
   public void updateCity(String id, String city)
        {
             addressBook.updatePersonCity(id,city);
        }
        
   public void updatePhone(String id, String phone)
        {
            addressBook.updatePersonPhone(id,phone);
        }
        
   public boolean checkPersonId(String personid)
        {
            return addressBook.checkPersonId(personid);
        }
   // end calling methods from the ModemLayer      
}
